import Login from '../page/Login';
import Layout from '../page/Layout';
import About from '../page/About';
import Board from '../page/Board'
import NotFound from '../page/NotFound';
import Article from "../page/Article";
import {createBrowserRouter,createHashRouter} from 'react-router-dom';

/**
 * createBrowserRouter --  createHashRouter 两种路由模式
 * 
 * createBrowserRouter -> history对象 + pushState事件 需要后端支持
 * createHashRouter   ->  监听hashChange事件   ->不需要后端支持
 * 
 * 
 */

const myrouter = createHashRouter([
    {
        path:'/login',
        element:<Login/>
    },
    {
        path:'/article/:id/:name',
        element:<Article/>
    },
    {
        /** 一级路由 */
        path:'/',
        element:<Layout/>,
        children:[
            {       /** 二级路由 */
                // path:'board', 默认二级路由设置
                index:true,    
                element:<Board/>
            },
            {
                path:'about',
                element:<About/>
            }
        ]
    },
    {
        /** 404 路由 */
        path:'*',
        element:<NotFound/>
    }
])

export default myrouter